package com.mio.hdfs.sort;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.WritableComparable;

public class SortBean implements WritableComparable<SortBean>{
	
	private Integer index;
	
	private Integer num;
	
	

	public SortBean() {
		
	}

	public void readFields(DataInput in) throws IOException {
		this.index = in.readInt();
		this.num = in.readInt();
		
	}

	public void write(DataOutput out) throws IOException {
		out.writeInt(index);
		out.writeInt(num);
		
	}

	public int compareTo(SortBean o) {
		if(this.num > o.num ) {
			return 1;
		}else if(this.num < o.num ) {
			return -1;
		}
		return 0;
	}

	
	
	@Override
	public String toString() {
		return  index + "\t" + num ;
	}

	public Integer getIndex() {
		return index;
	}

	public void setIndex(Integer index) {
		this.index = index;
	}

	public Integer getNum() {
		return num;
	}

	public void setNum(Integer num) {
		this.num = num;
	}
	
	
	
	

}
